layui.define(['Mock', 'apiCommon', 'qs'], function (exports) {
	var Mock = layui.Mock,
		api = layui.apiCommon.api,
		qs = layui.qs;

	function commonMock() {
		Mock.setup({
			timeout: '50-500'
		})

		/**
		 * @author: ares
		 * @date: 2020/1/29 13:25
		 * @description: 获取主菜单
		 */
		Mock.mock(RegExp(api.getMainMenu + '[^\.]*$'), {
			code: 2000,
			msg: '获取主菜单成功',
			data: [
				{
					id: 1,
					icon: 'fa-asterisk',
					name: '内容管理'
				},
				{
					id: 2,
					icon: 'fa-file',
					name: '文件管理'
				}
			]
		})

		/**
		 * @author: ares
		 * @date: 2020/1/29 13:25
		 * @description: 获取侧边菜单
		 */
		Mock.mock(RegExp(api.getSideMenu + '[^\.]*$'), function (options) {
			var params = qs.parse(options.url.split('?')[1]),
				mainMenuId = params.id,
				usedMenu = [
					{
						"title": "首页",
						"icon": "fa-home",
						"href": "/homepage",
						"spread": false
					},
					{
						"title": "系统管理",
						"icon": "fa-cogs",
						"href": "",
						"spread": false,
						"children": [
							{
								"title": "用户管理",
								"icon": "fa-users",
								"href": "/setting/user",
								"spread": false
							}
						]
					},
				];
			return {
				code: 2000,
				msg: '获取侧边菜单成功',
				data: mainMenuId ? menu[mainMenuId] : usedMenu
			}
		})

		/**
		 * @author: ares
		 * @date: 2021/4/27 22:26
		 * @description: 获取未读消息数
		 */
		Mock.mock(RegExp(api.getUnreadMsgCount + '[^\.]*$'), function (options) {
			return Mock.mock({
				code: 2000,
				msg: '获取未读消息数成功',
				data: '@integer(0, 10)'
			})
		})
	}

	exports("commonMock", commonMock);
})